<!--#
layout("/layouts/platform.html"){
#-->
<!--后台用户管理页面-->
<div id="app" v-cloak>
    <el-row class="header navbar bg-white shadow">
        <el-row>
            <!--搜索条件-->
            <div class="btn-group tool-button mt5">
                <el-date-picker
                        v-model="searchDate"
                        type="datetimerange"
                        :picker-options="pickerOptions"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        align="right"
                        size="medium"
                        :default-time="['00:00:00', '23:59:59']"
                        value-format="yyyy-MM-dd HH:mm:ss">
                </el-date-picker>
            </div>
            <!--搜索用户-->
            <div class="btn-group tool-button mt5">
                <el-input v-model="pageForm.userKeyword" @keyup.enter.native="doSearch('user')"
                          placeholder="搜索用户(用户名|ip|电话|昵称)"
                          size="medium"></el-input>
            </div>
            <!--搜索下一级邀请人-->
            <div class="btn-group tool-button mt5">
                <el-input v-model="pageForm.inviterKeyword" @keyup.enter.native="doSearch('inviter')"
                          placeholder="搜索下一级邀请人"
                          size="medium"></el-input>
            </div>
            <!--新增按钮-->
            <div class="pull-right offscreen-right mt5">
                <el-button type="danger" @click="openTransactionPassword">内部账号交易密码</el-button>
                <el-button size="medium" @click="openAdd"><i class="ti-plus"></i>添加用户</el-button>
            </div>
            <div class="btn-group tool-button mt5">
                <el-checkbox v-model="isOnline">是否在线</el-checkbox>
            </div>
            <div class="btn-group tool-button mt5">
                <el-checkbox v-model="disabled">是否禁用</el-checkbox>
            </div>
            <div class="btn-group tool-button mt5">
                <el-checkbox v-model="sessionDisabled">是否禁言</el-checkbox>
            </div>
            <div class="btn-group tool-button mt5">
                <el-checkbox v-model="isAttendant">是否客服</el-checkbox>
            </div>
            <div class="btn-group tool-button mt5">
                <el-checkbox v-model="isInside">是否内部账号</el-checkbox>
            </div>
            <div class="btn-group tool-button mt5">
                <el-checkbox v-model="isVisitor">不显示游客</el-checkbox>
            </div>
            <!--搜索按钮-->
            <div class="btn-group tool-button mt5">
                <el-button slot="append" icon="el-icon-search" @click="doSearch" size="medium"></el-button>
            </div>
        </el-row>
    </el-row>
    <el-row class="el-table-container" style="padding-top:85px">
        <el-table
                :data="tableData"
                size="small"
                header-align="center"
                style="width: 100%">
            <!--昵称-->
            <el-table-column
                    fixed="left"
                    label="昵称"
                    prop="nickName"
                    header-align="center"
                    :show-overflow-tooltip="true"
                    align="center">
            </el-table-column>
            <!--用户名-->
            <el-table-column
                    fixed="left"
                    prop="userName"
                    label="用户名"
                    header-align="center"
                    align="center">
            </el-table-column>
            <!--真实姓名-->
            <el-table-column
                    fixed="left"
                    prop="realName"
                    label="真实姓名"
                    header-align="center"
                    align="center">
            </el-table-column>
            <!--邮箱-->
            <el-table-column
                    fixed="left"
                    prop="email"
                    label="邮箱"
                    header-align="center"
                    width="120px"
                    align="center">
            </el-table-column>
            <!--手机号-->
            <el-table-column
                    fixed="left"
                    prop="phone"
                    label="手机"
                    header-align="center"
                    width="120px"
                    align="center">
                <template slot-scope="scope">
                    <span v-if="scope.row.phone">{{'(+' + scope.row.phonePrefix + ')' + scope.row.phone}}</span>
                </template>
            </el-table-column>
            <!--备注-->
            <el-table-column
                    fixed="left"
                    label="备注"
                    prop="remark"
                    header-align="center"
                    :show-overflow-tooltip="true"
                    align="center">
            </el-table-column>
            <!--提现流水倍数-->
            <el-table-column
                    prop="multiple"
                    label="提现流水倍数"
                    header-align="center"
                    align="center">
            </el-table-column>
            <!--提现流水倍数-->
            <el-table-column
                    prop="transRestriction"
                    label="提现流水额度"
                    header-align="center"
                    align="center">
            </el-table-column>
            <!--有效流水-->
            <el-table-column
                    prop="effectQuota"
                    label="有效流水"
                    header-align="center"
                    align="center">
            </el-table-column>
            <!--邀请码-->
            <el-table-column
                    prop="inviteCode"
                    label="邀请码"
                    header-align="center"
                    align="center">
            </el-table-column>
            <!--邀请人-->
            <el-table-column
                    prop="inviter"
                    label="邀请人"
                    header-align="center"
                    align="center">
            </el-table-column>
            <!--邀请数量-->
            <el-table-column
                    prop="invitedNum"
                    label="邀请数量"
                    header-align="center"
                    align="center">
            </el-table-column>
            <!--禁言设置-->
            <el-table-column
                    prop="sessionDisabled"
                    label="是否禁言"
                    header-align="center"
                    align="center">
                <template slot-scope="scope">
                    <i v-if="scope.row.sessionDisabled" class="fa fa-circle text-success ml5"></i>
                    <i v-if="!scope.row.sessionDisabled" class="fa fa-circle text-danger ml5"></i>
                </template>
            </el-table-column>
            <!--User启用状态-->
            <el-table-column
                    prop="disabled"
                    label="账号启用状态"
                    header-align="center"
                    align="center">
                <template slot-scope="scope">
                    <el-tooltip v-if="!scope.row.disabled" effect="light" placement="left" content="启用">
                        <i class="fa fa-circle text-success ml5"></i>
                    </el-tooltip>
                    <el-tooltip v-if="scope.row.disabled" effect="light" placement="left" content="禁用">
                        <i class="fa fa-circle text-danger ml5"></i>
                    </el-tooltip>
                </template>
            </el-table-column>
            <!--是否在线-->
            <el-table-column
                    fixed="right"
                    prop="isOnline"
                    label="登录状态"
                    header-align="center"
                    align="center">
                <template slot-scope="scope">
                    <el-tooltip v-if="scope.row.isOnline" effect="light" placement="left" content="在线">
                        <i class="fa fa-circle text-success ml5"></i>
                    </el-tooltip>
                    <el-tooltip v-if="!scope.row.isOnline" effect="light" placement="left" content="离线">
                        <i class="fa fa-circle text-danger ml5"></i>
                    </el-tooltip>
                </template>
            </el-table-column>
            <!--登录ip-->
            <el-table-column
                    fixed="right"
                    prop="ip"
                    label="登录ip"
                    header-align="center"
                    width="120px"
                    align="center">
                <template slot-scope="scope">
                    <span v-if="scope.row.ip">{{scope.row.ip}}</span>
                    <span v-else>未登录</span>
                </template>
            </el-table-column>
            <!--最后登录时间-->
            <el-table-column
                    fixed="right"
                    prop="lastLoginAt"
                    label="最后登录时间"
                    header-align="center"
                    align="center"
                    width="120px">
                <template slot-scope="scope">
                    {{formatAt(scope.row.lastLoginAt)}}
                </template>
            </el-table-column>
            <!--总登录时长(h)-->
            <el-table-column
                    fixed="right"
                    prop="loginDuration"
                    label="总登录时长(h)"
                    header-align="center"
                    align="center"
                    width="120px">
            </el-table-column>
            <!--创建时间-->
            <el-table-column
                    fixed="right"
                    prop="ctAt"
                    label="创建时间"
                    header-align="center"
                    align="center"
                    width="120px">
                <template slot-scope="scope">
                    {{formatAt(scope.row.ctAt)}}
                </template>
            </el-table-column>
            <!--操作下拉菜单-->
            <el-table-column
                    fixed="right"
                    label="操作"
                    width="120"
                    align="center">
                <template slot-scope="scope">
                    <el-dropdown @command="dropdownCommand">
                        <el-button size="mini">
                            <i class="ti-settings"></i>
                            <span class="ti-angle-down"></span>
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item divided :command="{type:'edit',id:scope.row.id}">
                                修改用户
                            </el-dropdown-item>
                            <el-dropdown-item divided :command="{type:'invitedUser',id:scope.row.id}">
                                查看邀请
                            </el-dropdown-item>
                            <el-dropdown-item divided :command="{type:'delete',id:scope.row.id,name:scope.row.userName}"
                                              v-if="scope.row.visitor">
                                删除
                            </el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </template>
            </el-table-column>
        </el-table>
    </el-row>
    <!--分页容器-->
    <el-row class="el-pagination-container">
        <div class="pull-left offscreen-right mt5">
            <el-pagination
                    @size-change="pageSizeChange"
                    @current-change="pageNumberChange"
                    :current-page="pageForm.pageNumber"
                    :page-sizes="[10, 20, 30, 50]"
                    :page-size="pageForm.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pageForm.totalCount">
            </el-pagination>
        </div>
        <div class="pull-right offscreen-right mt5">
            <span style="color: red">在线人数： {{onlineNum}}</span>
        </div>
    </el-row>
    <!--新增/修改按钮弹出的dialog-->
    <el-dialog
            :title="titlePopu==0?'新增用户':'修改用户'"
            :visible.sync="editDialogVisible"
            :close-on-click-modal="false"
            width="40%">
        <el-row>
            <el-form :model="formData" ref="editForm" :rules="titlePopu==0?formRules:''" size="small"
                     label-width="110px">
                <!--            新增/修改昵称input-->
                <el-form-item prop="userName" :label="titlePopu==0?'输入用户名':'修改用户名'">
                    <el-input maxlength="100" :placeholder="titlePopu==0?'输入用户名':'修改用户名'"
                              v-model="formData.userName"
                              :disabled="titlePopu==0?false:true"
                              auto-complete="off"
                              tabindex="1"
                              type="text"
                    >
                    </el-input>
                </el-form-item>
                <!--            修改手机号input-->
                <el-form-item prop="phone" v-if="titlePopu==1" label="修改手机号">
                    <el-input maxlength="100"
                              placeholder="修改手机号"
                              v-model="formData.phone"
                              auto-complete="off"
                              onkeyup="value=value.replace(/[^\d]/g,'');"
                              type="text">
                    </el-input>
                </el-form-item>
                <!--            修改真实姓名input-->
                <el-form-item prop="transactionPwd" v-if="titlePopu==1" label="修改真实姓名">
                    <el-input maxlength="100"
                              placeholder="修改真实姓名"
                              v-model="formData.realName"
                              auto-complete="off"
                              tabindex="1"
                              type="text">
                    </el-input>
                </el-form-item>
                <!--            新增/修改登录密码input-->
                <el-form-item prop="pwd" :label="titlePopu==0?'输入登录密码':'修改登录密码'">
                    <el-input maxlength="100"
                              :placeholder="titlePopu==0?'输入登录密码':'修改登录密码'"
                              v-model="formData.pwd"
                              auto-complete="off"
                              :value="titlePopu==0?'123456':''"
                              tabindex="1"
                              type="password">
                    </el-input>
                </el-form-item>
                <!--            修改交易密码input-->
                <el-form-item prop="transactionPwd" v-if="titlePopu==1" label="修改交易密码">
                    <el-input maxlength="100"
                              placeholder="修改交易密码"
                              v-model="formData.transactionPwd"
                              auto-complete="off"
                              tabindex="1"
                              type="password">
                    </el-input>
                </el-form-item>
                <el-form-item prop="inviteCode" :label="titlePopu==0?'输入邀请码':'修改邀请人'">
                    <el-input maxlength="100"
                              v-model="formData.inviteCode"
                              placeholder="输入邀请人的邀请码"
                              auto-complete="off"
                              tabindex="1"
                              type="text">
                    </el-input>
                </el-form-item>
                <el-form-item prop="withdrawFreeTimes" label="月免次">
                    <el-input v-model="formData.withdrawFreeTimes"
                              placeholder="每月免手续费提现次数"
                              auto-complete="off"
                              tabindex="1"
                              type="number">
                    </el-input>
                </el-form-item>

                <el-form-item prop="multiple" label="提现流水倍数">
                    <el-input v-model="formData.multiple"
                              placeholder="提现流水倍数"
                              auto-complete="off"
                              tabindex="1"
                              type="number">
                    </el-input>
                </el-form-item>

                <el-form-item prop="transRestriction" label="提现流水额度">
                    <el-input v-model="formData.transRestriction"
                              placeholder="transRestriction"
                              auto-complete="off"
                              tabindex="1"
                              type="number">
                    </el-input>
                </el-form-item>

                <!--            新增/修改User类型switch-->
                <el-col :span="6">
                    <!--禁言设置-->
                    <el-form-item
                            prop="sessionDisabled"
                            label="是否禁言">
                        <el-switch
                                v-model="formData.sessionDisabled"
                                active-color="#13ce66"
                                inactive-color="#909399">
                        </el-switch>
                    </el-form-item>
                </el-col>

                <el-col :span="6">
                    <!--User启用状态-->
                    <el-form-item
                            prop="disabled"
                            label="禁用">
                        <el-switch
                                v-model="formData.disabled"
                                active-color="#13ce66"
                                inactive-color="#909399">
                        </el-switch>
                    </el-form-item>
                </el-col>

                <el-col :span="6">
                    <!--客服-->
                    <el-form-item
                            prop="attendant"
                            label="客服">
                        <el-switch
                                v-model="formData.attendant"
                                active-color="#13ce66"
                                inactive-color="#909399">
                        </el-switch>
                    </el-form-item>
                </el-col>

                <el-col :span="6">
                    <!--内部账号-->
                    <el-form-item
                            prop="inside"
                            label="内部账号">
                        <el-switch
                                v-model="formData.inside"
                                active-color="#13ce66"
                                inactive-color="#909399">
                        </el-switch>
                    </el-form-item>
                </el-col>

                <el-col :span="24">
                    <el-form-item prop="remark" label="备注">
                        <el-input maxlength="100"
                                  v-model="formData.remark"
                                  placeholder="输入备注"
                                  auto-complete="off"
                                  type="textarea">
                        </el-input>
                    </el-form-item>
                </el-col>
            </el-form>
        </el-row>
        <!--        确认/取消 提交修改按钮-->
        <el-row>
            <el-col :span="8">
                <span>&nbsp;</span>
            </el-col>
            <el-col :span="8">
                <el-button @click="editDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="doEdit">确 定</el-button>
            </el-col>
            <el-col :span="8">
                <span>&nbsp;</span>
            </el-col>
        </el-row>
    </el-dialog>
    <!--查看邀请人dialog-->
    <el-dialog
            title="邀请的用户"
            :visible.sync="inviterDialogVisible"
            :close-on-click-modal="false"
            width="40%">
        <el-row class="navbar bg-white">
            <el-row>
                <!--搜索条件-->
                <div class="btn-group tool-button mt5">
                    <el-date-picker
                            v-model="inviterSearchDate"
                            type="datetimerange"
                            :picker-options="pickerOptions"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            align="right"
                            size="medium"
                            :default-time="['00:00:00', '23:59:59']"
                            value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                </div>
                <!--按层级搜索-->
                <div class="btn-group tool-button mt5">
                    <el-input v-model="inviterPageForm.level" @keyup.enter.native="inviterDoSearch"
                              placeholder="按层级搜索" size="medium">
                    </el-input>
                </div>
                <!--搜索按钮-->
                <div class="btn-group tool-button mt5">
                    <el-button slot="append" icon="el-icon-search" @click="inviterDoSearch" size="medium"></el-button>
                </div>
            </el-row>
        </el-row>
        <el-row class="el-table-container" style="padding-top:0">
            <el-table
                    v-loading="inviterTableLoading"
                    :data="inviterTableData"
                    size="small"
                    border
                    :summary-method="getSummaries"
                    show-summary
                    header-align="center"
                    style="width: 100%">
                <!--昵称-->
                <el-table-column
                        label="昵称"
                        prop="nickName"
                        header-align="center"
                        :show-overflow-tooltip="true"
                        align="center">
                </el-table-column>
                <!--用户名-->
                <el-table-column
                        prop="userName"
                        label="用户名"
                        header-align="center"
                        align="center">
                </el-table-column>
                <!--层级-->
                <el-table-column
                        prop="level"
                        label="层级"
                        header-align="center"
                        align="center">
                </el-table-column>
                <!--收益-->
                <el-table-column
                        prop="earned"
                        label="收益$"
                        header-align="center"
                        align="center">
                </el-table-column>
                <!--下级充值总额(换算美金)-->
                <el-table-column
                        prop="totalRecharge"
                        label="下级充值总额$"
                        header-align="center"
                        align="center">
                </el-table-column>
                <!--下级提现总额(换算美金)-->
                <el-table-column
                        prop="totalWithdraw"
                        label="下级提现总额$"
                        header-align="center"
                        align="center">
                </el-table-column>
                <!--下级投资总额(换算美金)-->
                <el-table-column
                        prop="totalInvest"
                        label="下级投资总额$"
                        header-align="center"
                        align="center">
                </el-table-column>
                <!--注册时间-->
                <el-table-column
                        prop="ctAt"
                        label="注册时间"
                        header-align="center"
                        align="center">
                    <template slot-scope="scope">
                        {{formatAt(scope.row.ctAt)}}
                    </template>
                </el-table-column>
            </el-table>
        </el-row>
        <!--分页容器-->
        <el-row class="el-pagination-container">
            <div class="pull-left offscreen-right mt5">
                <el-pagination
                        @size-change="inviterPageSizeChange"
                        @current-change="inviterPageNumberChange"
                        :current-page="inviterPageForm.pageNumber"
                        :page-sizes="[10, 20, 30, 50]"
                        :page-size="inviterPageForm.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="inviterPageForm.totalCount">
                </el-pagination>
            </div>
        </el-row>
    </el-dialog>

    <!-- 内部账号修改交易密码弹出的dialog -->
    <el-dialog
            title="内部账号交易密码修改"
            :visible.sync="transactionPassword"
            width="20%">
                <el-input placeholder="新交易密码"
                          show-password
                          v-model="transactionPwd">
                </el-input>

        <!--确认/取消 提交修改按钮-->
        <span slot="footer" class="dialog-footer">
            <el-button @click="transactionPassword = false">取 消</el-button>
            <el-button type="primary" :disabled = 'buttonDisabled' @click="transactionPasswordEdit(transactionPwd)">确 定</el-button>
        </span>
    </el-dialog>

</div>
<script src="${base!}/assets/platform/js/sha256.js"></script>
<script>
    vue = new Vue({
        el: "#app",
        data: function () {
            return {
                pickerOptions: {
                    disabledDate: function (time) {
                        return time.getTime() > new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000);
                    },
                    shortcuts: [{
                        text: '最近一周',
                        onClick: function (picker) {
                            var end = new Date();
                            var start = new Date();
                            var temp = moment().add(-1, 'weeks').valueOf();
                            start.setTime(temp);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一个月',
                        onClick: function (picker) {
                            var end = new Date();
                            var start = new Date();
                            var temp = moment().add(-1, 'months').valueOf();
                            start.setTime(temp);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近三个月',
                        onClick: function (picker) {
                            var end = new Date();
                            var start = new Date();
                            var temp = moment().add(-3, 'months').valueOf();
                            start.setTime(temp);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                // 内部账号修改交易密码
                transactionPassword: false,
                transactionPwd:'',
                // 禁用按钮
                buttonDisabled: false,
                searchDate: [],
                inviterSearchDate: [],
                addDialogVisible: false,
                editDialogVisible: false,
                inviterDialogVisible: false,
                inviterTableLoading: true,
                isOnline: false,
                disabled: false,
                sessionDisabled: false,
                isAttendant: false,
                isInside: false,
                isVisitor: true,
                titlePopu: 0,
                tableData: [],
                inviterTableData: [],
                pageForm: {
                    pageNumber: 1,
                    pageSize: 10,
                    totalCount: 0,
                    userType: "",
                    userKeyword: "",
                    inviterKeyword: "",
                    searchDate: "",
                    conditionData: "",
                },
                inviterPageForm: {
                    pageNumber: 1,
                    pageSize: 10,
                    totalCount: 0,
                    inviterSearchDate: "",
                    id: "",
                    level: ""
                },
                formData: {
                    userName: "",
                    email: "",
                    pwd: "",
                    transactionPwd: "",
                    realName: "",
                    phone: "",
                    remark: ""
                },
                formRules: {
                    // 新增User昵称必须填写。用户名无法修改。
                    userName: [
                        {required: true, message: '请输入用户名', trigger: 'blur'}
                    ],
                    pwd: [
                        {required: true, message: '请输入密码', trigger: 'blur'}
                    ],
                    withdrawFreeTimes: [
                        {required: true, message: '次数', trigger: 'blur'}
                    ],
                    multiple: [
                        {required: true, message: '提现流水倍数', trigger: 'blur'}
                    ],
                    transRestriction: [
                        {required: true, message: '提现流水额度', trigger: 'blur'}
                    ]
                },
                onlineNum: 0,
                sum: []
            }
        },
        methods: {
            getSummaries(param) {
                const {columns, data} = param;
                const sums = [];
                sums[3] = '总收益:' + this.sum.allSubEarned + '$';
                sums[4] = '总充值:' + this.sum.allSubRecharge + '$';
                sums[5] = '总提现:' + this.sum.allSubWithdraw + '$';
                sums[6] = '总投资:' + this.sum.allSubInvest + '$';
                return sums;
            },
            formatAt: function (val) {
                if (val > 0)
                    return moment(val * 1000).format("YYYY-MM-DD HH:mm");
                return "";
            },
            pageNumberChange: function (val) {//页码更新操作
                this.pageForm.pageNumber = val;
                this.pageData();
            },
            pageSizeChange: function (val) {//分页大小更新操作
                this.pageForm.pageSize = val;
                this.pageData();
            },
            pageData: function (type) {//加载分页数据
                var self = this;
                sublime.showLoadingbar();//显示loading
                if (self.searchDate) {
                    self.pageForm.searchDate = self.searchDate.toString();
                } else {
                    self.pageForm.searchDate = "";
                }
                self.pageForm.conditionData = "";
                if (self.isOnline) {
                    if (self.pageForm.conditionData === "") {
                        self.pageForm.conditionData = "isOnline";
                    } else {
                        self.pageForm.conditionData = self.pageForm.conditionData + ",isOnline";
                    }
                }
                if (self.disabled) {
                    if (self.pageForm.conditionData === "") {
                        self.pageForm.conditionData = "disabled";
                    } else {
                        self.pageForm.conditionData = self.pageForm.conditionData + ",disabled";
                    }
                }
                if (self.sessionDisabled) {
                    if (self.pageForm.conditionData === "") {
                        self.pageForm.conditionData = "sessionDisabled";
                    } else {
                        self.pageForm.conditionData = self.pageForm.conditionData + ",sessionDisabled";
                    }
                }
                if (self.isAttendant) {
                    if (self.pageForm.conditionData === "") {
                        self.pageForm.conditionData = "isAttendant";
                    } else {
                        self.pageForm.conditionData = self.pageForm.conditionData + ",isAttendant";
                    }
                }
                if (self.isInside) {
                    if (self.pageForm.conditionData === "") {
                        self.pageForm.conditionData = "isInside";
                    } else {
                        self.pageForm.conditionData = self.pageForm.conditionData + ",isInside";
                    }
                }
                if (self.isVisitor) {
                    if (self.pageForm.conditionData === "") {
                        self.pageForm.conditionData = "isVisitor";
                    } else {
                        self.pageForm.conditionData = self.pageForm.conditionData + ",isVisitor";
                    }
                }
                if (type === 'user') {
                    self.pageForm.inviterKeyword = '';
                } else if (type === 'inviter') {
                    self.pageForm.userKeyword = '';
                }
                $.post(base + "/platform/user/manager/data", self.pageForm, function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code === 0) {
                        self.tableData = data.data.pagination.list;
                        self.pageForm.totalCount = data.data.pagination.totalCount;
                        self.onlineNum = data.data.onlineNum;
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            doSearch: function (type) {
                this.pageForm.pageNumber = 1;
                this.pageData(type);
            },
            inviterDoSearch: function () {
                this.inviterPageForm.pageNumber = 1;
                this.inviterPageData();
            },
            inviterPageData: function () {
                var self = this;
                self.inviterTableLoading = true;
                if (self.inviterSearchDate) {
                    self.inviterPageForm.inviterSearchDate = self.inviterSearchDate.toString();
                } else {
                    self.inviterPageForm.inviterSearchDate = "";
                }
                $.post(base + "/platform/user/manager/invitedUser", self.inviterPageForm, function (data) {
                    if (data.code === 0) {
                        self.inviterTableData = data.data.pagination.list;
                        self.inviterPageForm.totalCount = data.data.pagination.totalCount;
                        self.sum = data.data.allSubReport;
                        self.inviterTableLoading = false;
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            inviterPageNumberChange: function (val) {//页码更新操作
                this.inviterPageForm.pageNumber = val;
                this.inviterPageData();
            },
            inviterPageSizeChange: function (val) {//分页大小更新操作
                this.inviterPageForm.pageSize = val;
                this.inviterPageData();
            },
            openAdd: function () {// 新建/修改User按钮逻辑
                var self = this;
                self.titlePopu = 0;
                this.editDialogVisible = true;
                if (this.$refs["editForm"]) {
                    this.$refs["editForm"].resetFields();
                }
                self.formData = {};
            },
            doEdit: function () { // 提交新增/修改
                var self = this;
                if (self.formData.pwd) {
                    self.formData.password = sha256_digest(self.formData.pwd);
                }
                if (self.formData.transactionPwd) {
                    self.formData.transactionPwd = sha256_digest(self.formData.transactionPwd);
                }
                self.$refs["editForm"].validate(function (valid) {
                    if (valid) {
                        //titlePopu=0是新增,1是修改
                        if (self.titlePopu === 0) {
                            // self.formData.password = sha256_digest(self.formData.pwd);
                            $.post(base + "/platform/user/manager/add", self.formData, function (data) {
                                if (data.code === 0) {
                                    self.$message({
                                        message: data.msg,
                                        type: 'success'
                                    });
                                    self.doSearch();
                                    self.editDialogVisible = false;
                                } else {
                                    self.$message({
                                        message: data.msg,
                                        type: 'error'
                                    });
                                }
                            }, "json");
                        } else {
                            $.post(base + "/platform/user/manager/editDo", self.formData, function (data) {
                                if (data.code === 0) {
                                    self.$message({
                                        message: data.msg,
                                        type: 'success'
                                    });
                                    self.doSearch();
                                    self.editDialogVisible = false;
                                } else {
                                    self.$message({
                                        message: data.msg,
                                        type: 'error'
                                    });
                                }
                            }, "json");
                        }
                    }
                });
            },
            dropdownCommand: function (command) {//监听下拉框事件
                var self = this;
                // 启用，禁用按钮
                if ("enable" === command.type || "disable" === command.type) {
                    $.post(base + "/platform/user/manager/" + command.type + "/" + command.id, {}, function (data) {
                        if (data.code === 0) {
                            self.$message({
                                message: data.msg,
                                type: 'success'
                            });
                            if ("disable" === command.type) {
                                command.row.disabled = true;
                            }
                            if ("enable" === command.type) {
                                command.row.disabled = false;
                            }
                        } else {
                            self.$message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }, "json");
                }
                // 修改按钮
                if ("edit" === command.type) {
                    $.post(base + "/platform/user/manager/edit/" + command.id, {}, function (data) {
                        if (data.code === 0) {
                            if (self.$refs["editForm"]) {// 清空校验提示
                                self.$refs["editForm"].resetFields();
                            }
                            // 加载后台表单数据
                            self.formData = data.data;
                            // 清空修改邀请人input
                            self.formData.inviteCode = '';
                            self.editDialogVisible = true;// 打开编辑窗口
                            self.titlePopu = 1;
                        } else {
                            self.$message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }, "json");
                }
                // 删除（仅限游客）
                if ("delete" === command.type) {
                    // 删除按钮
                    self.$confirm('确认删除【' + command.name + '】?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        callback: function (a, b) {
                            if ("confirm" === a) {//确认后再执行
                                $.post(base + "/platform/user/manager/delete", {"id": command.id}, function (data) {
                                    if (data.code === 0) {
                                        self.$message({
                                            message: data.msg,
                                            type: 'success'
                                        });
                                        self.doSearch();
                                        self.editDialogVisible = false;
                                    } else {
                                        self.$message({
                                            message: data.msg,
                                            type: 'error'
                                        });
                                    }
                                }, "json");
                            }
                        }
                    });
                }
                // 查看邀请用户
                if ("invitedUser" === command.type) {
                    self.inviterPageForm.pageNumber = 1;
                    self.inviterPageForm.id = command.id;
                    self.inviterDialogVisible = true;
                    self.inviterTableLoading = true;
                    $.post(base + "/platform/user/manager/invitedUser", self.inviterPageForm, function (data) {
                        if (data.code === 0) {
                            self.inviterTableData = data.data.pagination.list;
                            self.inviterPageForm.totalCount = data.data.pagination.totalCount;
                            self.sum = data.data.allSubReport;
                            self.inviterTableLoading = false;
                        } else {
                            self.$message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }, "json");
                }
            },
            // 内部账号修改交易密码dialog
            openTransactionPassword: function () {
                var self = this;
                self.transactionPwd = '';
                self.transactionPassword = true;
            },
            // 内部账号修改交易密码
            transactionPasswordEdit: function (val) {
                var self = this;
                if (!val) {
                    self.$message({
                        message: "交易密码不能为空",
                        type: 'error'
                    });
                    return;
                }
                self.buttonDisabled = true;
                $.post(base + "/platform/user/manager/insideTransactionPwdEdit", {'transactionPwd':sha256_digest(val)}, function (data) {
                    if (data.code === 0) {
                        self.$message({
                            message: data.msg,
                            type: 'success'
                        });
                        self.transactionPassword = false;
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                    self.buttonDisabled = false;
                }, "json");
            }
        },
        created: function () {
            this.pageData();
        }
    });
</script>

<!--#
}
#-->